home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / graphics / rmtc02.zip / WRITEXGF.C < prev   
Text File  |  1992-04-06  |  759b  |  40 lines

  1. #include <stdio.h>
  2. #include <alloc.h>
  3. #include <graphics.h>
  4.  
  5. void main()
  6. {
  7.   void *imgBuf;
  8.   FILE *F;
  9.   int driver = EGA;
  10.   int mode   = EGAHI;
  11.   unsigned int size;
  12.  
  13.   initgraph(&driver, &mode, "");
  14.  
  15.   setfillstyle(SOLID_FILL,BLUE);
  16.   bar(0,0,639,349);
  17.  
  18.   setfillstyle(SLASH_FILL,LIGHTGRAY);
  19.   bar(2,2,49,49);
  20.   setcolor(WHITE);
  21.   rectangle(1,1,50,50);
  22.   setcolor(LIGHTGREEN);
  23.   outtextxy(2,10,"RASTER");
  24.   outtextxy(2,30,"MASTER");
  25.  
  26.   size=imagesize(1,1,50,50);
  27.   imgBuf = malloc(size);
  28.   getimage(1,1,50,50,imgBuf);
  29.   if ((F=fopen("sample.xgf","wb")) == NULL)
  30.   {
  31.     closegraph();
  32.     printf("Can't open file!\n");
  33.     exit(0);
  34.   }
  35.   fwrite(imgBuf,size,1,F);
  36.   fclose(F);
  37.   free(imgBuf);
  38.   getch();
  39.   closegraph();
  40. }